package com.yjhb.android.sbz.mvp.refreshpackage;

import com.yjhb.android.sbz.App;
import com.yjhb.android.sbz.entity.Flush;
import com.yjhb.android.sbz.http.HttpObserver;
import com.yjhb.android.sbz.http.HttpTool;
import com.yjhb.android.sbz.mvp.ConventionPresenter;

import java.math.BigDecimal;

/**
 * 创建者 zx
 * 创建时间 2020/12/7 11:27
 */
public class RefreshPackagePresenter extends ConventionPresenter<RefreshPackageView> {
    private final String TAG = "RefreshPackagePresenter";

    @Override
    protected void onDestroy() {

    }

    public RefreshPackagePresenter(RefreshPackageView refreshPackageView) {
        super(refreshPackageView);
    }


    public void buyFlush(BigDecimal money) {
        if (checkUnLogin()) return;
        if (view != null) {
            view.onWait();
        }
        HttpTool.request(model.buyFlush(App.userInfo.getId(), money), new HttpObserver<Flush>() {
            @Override
            public void onResult(Flush data) {
                if (view != null) {
                    view.onBuy();
                }
            }

            @Override
            public void onError(int code, String msg) {
                if (view!=null){
                    view.onFailure(code, msg);
                }
            }
        });
    }

}
